<template>
	<view class="content">
		<view class="section-1">
			<view class="form">
				<view class="form-item">
					<view class="label">项目名称</view>
					<view class="shape"></view>
					<view class="input">
						<u--input
							placeholderClass="input-placeholder"
							class="input-body"
						    placeholder=""
						    v-model="name"
						  ></u--input>
					</view>
				</view>
				<view class="actions">
					<view class="action" @click="init()">
						<text>重</text>
						<text>置</text>
					</view>
					<view class="action search" @click="search()">
						<text>查</text>
						<text>询</text>
					</view>
				</view>
			</view>
			<view class="list">
				<view class="item" v-for="(item, idx) in list" :key="item.project_name + item.user_name + idx">
					<view class="text">
						<view class="poss">{{item.user_name}}</view>
						<!-- <view class="texts">{{item.time}}</view> -->
					</view>
					<view class="text-1">{{item.project_name}}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { mapGetters } from 'vuex';
	import { performListApi } from '@/api/statistics.js';
	export default {
		data() {
			return {
				name: '',
				olist:[],
				list:[],
				type: 1
			};
		},
		computed: {
			...mapGetters({start_time: 'duty/getStartTime', end_time: 'duty/getEndTime'}),
		},
		methods:{
			// go(item) {
			// 	uni.navigateTo({
			// 		url: item.path
			// 	})
			// }
			search() {
				let arr = []
				for(let key in this.olist) {
					if (this.olist[key].project_name.indexOf(this.name) !== -1) {
						arr.push(this.olist[key])
					}
				}
				this.list = JSON.parse(JSON.stringify(arr))
			},
			init() {
				this.name = ''
				this.list = JSON.parse(JSON.stringify(this.olist))
			},
			async fetchData() {
				uni.showLoading({title: '加载中...'});
				const { data } = await performListApi(
					{
						type: 1,
						start_time: this.start_time,
						end_time: this.end_time,
						time_type: this.type,
					}
				);
				uni.hideLoading();
				if (data.code === 1) {
					this.olist = data.data;
					this.list = data.data
				} 
			}
		},
		onReady() {
			this.fetchData();
		},
		onLoad(data) {
			this.type = data.type
			if (this.type == 1) {
				uni.setNavigationBarTitle({
					title: '本日履职总人次数'
				})
			} else if (this.type == 2) {
				uni.setNavigationBarTitle({
					title: '本周履职总人次数'
				})
			} else if (this.type == 3) {
				uni.setNavigationBarTitle({
					title: '本月履职总人次数'
				})
			} else if (this.type == 4) {
				uni.setNavigationBarTitle({
					title: '全部履职总人次数'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content{
		background-color: #2c5cfd;
	}
	.section-1{
		position: relative;
		z-index: 10;
		background-color: #fff;
		border-top-left-radius: 50rpx;
		border-top-right-radius: 50rpx;
		.list{
			width: 670rpx;
			box-sizing: border-box;
			margin-left: 40rpx;
			border-top: 2rpx solid #d8e4f2;
			.item{
				box-sizing: border-box;
				width: 100%;
				border-bottom: solid 2rpx #f2f2f0;
				letter-spacing: 2rpx;
				color: #3b3c40;
				padding: 20rpx 30rpx;
				
				.text{
					width: 100%;
					height: 46rpx;
					line-height: 46rpx;
					@include clear();
					.poss{
						float: left;
						font-size: 26rpx;
						font-weight: bold;
						color: #3b3c40;
					}
					.texts{
						float: left;
						font-size: 16rpx;
						color: #7b9bb2;
						margin-left: 50rpx;
					}
				}
				.text-1{
					font-size: 16rpx;
					color: #7b9bb2;
					text-overflow: ellipsis;
					overflow: hidden;
					white-space: nowrap;
				}
			}
		}
		.actions{
			width: 100%;
			height: 50rpx;
			margin-top: 29rpx;
			padding-bottom: 40rpx;
			display: flex;
			justify-content: space-between;
			.action{
				width: 288rpx;
				height: 48rpx;
				background-color: #395cf5;
				border-radius: 20rpx;
				text-align: center;
				line-height: 48rpx;
				font-size: 26rpx;
				font-weight: normal;
				font-stretch: normal;
				color: #ffffff;
				text{
					&:first-child{
						margin-right: 20rpx;
					}
				}
			}
			.search{
				background-color: #1534ce;
			}
		}
		.form{
			width: 100%;
			padding: 0 75rpx;
			padding-top: 40rpx;
			box-sizing: border-box;
			.form-item{
				width: 600rpx;
				height: 48rpx;
				border-radius: 20rpx;
				border: solid 2rpx #1534ce;
				margin: 0 auto;
				margin-bottom: 34rpx;
				@include clear();
				.label{
					float: left;
					width: 134rpx;
					height: 48rpx;
					text-align: center;
					line-height: 44rpx;
					font-size: 26rpx;
					font-weight: normal;
					font-stretch: normal;
					letter-spacing: 0rpx;
					color: #1534ce;
				}
				.shape{
					width: 3rpx;
					height: 32rpx;
					background-color: #7f98ae;
					float: left;
					margin-top: 8rpx;
				}
				.input{
					float: left;
					width: calc(100% - 134rpx - 3rpx);
					.input-body{
						box-sizing: border-box;
						width: 100%;
						height: 44rpx;
						padding: 0!important;
						border: none;
						padding-left: 30rpx!important;
						padding-right: 30rpx!important;
						font-size: 26rpx;
						font-weight: normal;
						font-stretch: normal;
						letter-spacing: 0rpx;
						color: rgba(0,0,0,0.7);
					}
					.input-placeholder{
						font-size: 26rpx;
						font-weight: normal;
						font-stretch: normal;
						letter-spacing: 0rpx;
						color: rgba(0,0,0,0.5);
					}
				}	
			}
		}
	}
</style>
